package lock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * 
 * @author lcx
 *
 */
public class ReentrantLockTest {
	
	public static void main(String[] args) {
		ReentrantLock lock=new ReentrantLock();
		LockThread td1=new LockThread(lock);
		LockThread td2=new LockThread(lock);
		td1.start();
		td2.start();
	}
}

class LockThread extends Thread
{
	ReentrantLock lock;
	public LockThread(ReentrantLock lock)
	{
		this.lock=lock;
	}
	
	@Override
	public void run()
	{
		lock.lock();
		System.out.println("start......");
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		lock.unlock();
		System.out.println("end");
	}
}
